﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using TimKen.DataEntity;


namespace TimKen.Web.Admin.Authority
{
    public partial class DataAdmin_List : TimKen.App.AdminPage
    {
        TimKen.BussLogic.UserAccountManager ua = new TimKen.BussLogic.UserAccountManager();
        TimKen.BussLogic.CustomerManager cm = new TimKen.BussLogic.CustomerManager();

        public override string ActionCode
        {
            get
            {
                return "8";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                BindGrid();
                BindResources();
            }
        }

        private void BindGrid()
        {
            grdUserList.DataSource = ua.GetUserAccountPageList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex,"1",
             "-1", txtUserName.Text.Trim(), this.LanguageID);
            grdUserList.DataBind();
        }
       
        protected void btFilter_Click(object sender, EventArgs e)
        {
            BindGrid();
        }

        protected void btNoFilter_Click(object sender, EventArgs e)
        {
            txtUserName.Text = "";
            BindGrid();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindGrid();
        }

        protected void grdUserList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteUser")
            {
                //未完成
                ua.Delete(e.CommandArgument.ToString(), "CurrentUser");
                BindGrid();
            }
        }

        public void BindResources()
        {
            btFilter.Text = GetLangString("Search");
            btNoFilter.Text = GetLangString("ClearSearchCondition");
        }
    }
}
